public class StringEquality {

  public static void main(String[] args) {
    String greeting = "Hello";

    if (greeting.equals("Hello"))
      System.out.println("I use `equals` method");

    if (greeting == "Hello")
      System.out.println("The `==` method worked.");
    else
      System.out.println("The `==` method didn't work.");

    if (greeting.substring(0, 3).equals("Hel"))
      System.out.println("I use `equals` method");

    if (greeting.substring(0, 3) == "Hel")
      System.out.println("The `==` method worked.");
    else
      System.out.println("The `==` method didn't work.");
  }

}
